package br.com.webhomesites.configuracao.view;

import br.com.webhomesites.configuracao.contracts.IEmpresaView;
import br.com.webhomesites.configuracao.model.CidadeModel;
import br.com.webhomesites.configuracao.model.EstadoModel;
import br.com.webhomesites.configuracao.utils.ConfiguracaoInstancias;
import java.awt.Component;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.*;

public class EmpresaView extends javax.swing.JInternalFrame implements IEmpresaView {
     
    //construtor da classe. carrega os componentes
    public EmpresaView() {
        initComponents();        
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        painelCentralEmpresa = new javax.swing.JPanel();
        labelEmpresaRazaoSocial = new javax.swing.JLabel();
        txtEmpresaRazaoSocial = new javax.swing.JTextField();
        labelEmpresaCodigo = new javax.swing.JLabel();
        labeEmpresaCNPJ = new javax.swing.JLabel();
        txtEmpresaCNPJ = new javax.swing.JTextField();
        txtEmpresaCodigo = new javax.swing.JTextField();
        labelEmpresaInscriacoEstadual = new javax.swing.JLabel();
        labelEmpresaEndereco = new javax.swing.JLabel();
        txtEmpresaEndereco = new javax.swing.JTextField();
        txtEmpresaBairro = new javax.swing.JTextField();
        labelEmpresaBairro = new javax.swing.JLabel();
        labelEmpresaCidade = new javax.swing.JLabel();
        comboEmpresaCidade = new javax.swing.JComboBox();
        labelEmpresaTelefone = new javax.swing.JLabel();
        txtEmpresaTelefone = new javax.swing.JTextField();
        txtEmpresaEmail = new javax.swing.JTextField();
        labelEmpresaEmail = new javax.swing.JLabel();
        labelEmpresaEstado = new javax.swing.JLabel();
        comboEmpresaEstado = new javax.swing.JComboBox();
        txtEmpresaInscricaoEstadual = new javax.swing.JTextField();
        btnNovo = new javax.swing.JButton();
        btnRemover = new javax.swing.JButton();
        btnSalvar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        btnPesquisar = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);

        painelCentralEmpresa.setBorder(javax.swing.BorderFactory.createTitledBorder("Cadastro de Empresa"));

        labelEmpresaRazaoSocial.setText("Razão Social");

        txtEmpresaRazaoSocial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtEmpresaRazaoSocialActionPerformed(evt);
            }
        });

        labelEmpresaCodigo.setText("Cód.Empresa");

        labeEmpresaCNPJ.setText("CNPJ");

        txtEmpresaCodigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtEmpresaCodigoActionPerformed(evt);
            }
        });

        labelEmpresaInscriacoEstadual.setText("Inscrição Estadual");

        labelEmpresaEndereco.setText("Endereço");

        labelEmpresaBairro.setText("Bairro");

        labelEmpresaCidade.setText("Cidade");

        labelEmpresaTelefone.setText("Telefone");

        labelEmpresaEmail.setText("E-mail");

        labelEmpresaEstado.setText("Estado");

        javax.swing.GroupLayout painelCentralEmpresaLayout = new javax.swing.GroupLayout(painelCentralEmpresa);
        painelCentralEmpresa.setLayout(painelCentralEmpresaLayout);
        painelCentralEmpresaLayout.setHorizontalGroup(
            painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelCentralEmpresaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(painelCentralEmpresaLayout.createSequentialGroup()
                        .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(labelEmpresaCodigo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtEmpresaCodigo))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(painelCentralEmpresaLayout.createSequentialGroup()
                                .addComponent(labelEmpresaRazaoSocial)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(txtEmpresaRazaoSocial)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelCentralEmpresaLayout.createSequentialGroup()
                        .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(painelCentralEmpresaLayout.createSequentialGroup()
                                .addComponent(labeEmpresaCNPJ)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(txtEmpresaCNPJ))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(painelCentralEmpresaLayout.createSequentialGroup()
                                .addComponent(labelEmpresaInscriacoEstadual)
                                .addGap(162, 162, 162))
                            .addComponent(txtEmpresaInscricaoEstadual)))
                    .addGroup(painelCentralEmpresaLayout.createSequentialGroup()
                        .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelEmpresaTelefone)
                            .addComponent(txtEmpresaTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtEmpresaEmail)
                            .addGroup(painelCentralEmpresaLayout.createSequentialGroup()
                                .addComponent(labelEmpresaEmail)
                                .addGap(0, 0, Short.MAX_VALUE))))
                    .addGroup(painelCentralEmpresaLayout.createSequentialGroup()
                        .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelEmpresaCidade)
                            .addComponent(labelEmpresaEstado))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(painelCentralEmpresaLayout.createSequentialGroup()
                        .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(comboEmpresaCidade, javax.swing.GroupLayout.Alignment.LEADING, 0, 259, Short.MAX_VALUE)
                            .addComponent(comboEmpresaEstado, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtEmpresaEndereco, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelEmpresaEndereco, javax.swing.GroupLayout.Alignment.LEADING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(painelCentralEmpresaLayout.createSequentialGroup()
                                .addComponent(labelEmpresaBairro)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(txtEmpresaBairro))))
                .addContainerGap())
        );
        painelCentralEmpresaLayout.setVerticalGroup(
            painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelCentralEmpresaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelEmpresaRazaoSocial)
                    .addComponent(labelEmpresaCodigo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmpresaRazaoSocial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtEmpresaCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labeEmpresaCNPJ)
                    .addComponent(labelEmpresaInscriacoEstadual))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmpresaCNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtEmpresaInscricaoEstadual, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelEmpresaTelefone)
                    .addComponent(labelEmpresaEmail))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmpresaTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtEmpresaEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelEmpresaEndereco)
                    .addComponent(labelEmpresaBairro))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(painelCentralEmpresaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmpresaEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtEmpresaBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(labelEmpresaEstado)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
                .addComponent(comboEmpresaEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(13, 13, 13)
                .addComponent(labelEmpresaCidade)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(comboEmpresaCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        btnNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/document-icon.png"))); // NOI18N
        btnNovo.setMnemonic('n');
        btnNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoActionPerformed(evt);
            }
        });

        btnRemover.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/delete-icon.png"))); // NOI18N
        btnRemover.setMnemonic('x');
        btnRemover.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoverActionPerformed(evt);
            }
        });

        btnSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/save-icon.png"))); // NOI18N
        btnSalvar.setMnemonic('s');
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });

        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/block-icon.png"))); // NOI18N
        btnCancelar.setMnemonic('c');
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnPesquisar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/search-icon.png"))); // NOI18N
        btnPesquisar.setMnemonic('p');
        btnPesquisar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPesquisarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnNovo, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnRemover, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnPesquisar, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 173, Short.MAX_VALUE))
                    .addComponent(painelCentralEmpresa, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(painelCentralEmpresa, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(btnSalvar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnRemover, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnPesquisar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnNovo, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    //ação do botão salvar
    private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
 
    }//GEN-LAST:event_btnSalvarActionPerformed
    //ação do botão novo
    private void btnNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoActionPerformed
       
    }//GEN-LAST:event_btnNovoActionPerformed
    //ação do botão pesquisar
    private void btnPesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarActionPerformed
     
        
    }//GEN-LAST:event_btnPesquisarActionPerformed
    //ação do botão cancelar
    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
      
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void btnRemoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoverActionPerformed
       
    }//GEN-LAST:event_btnRemoverActionPerformed
    //ação do campo do código do usuário
    private void txtEmpresaCodigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtEmpresaCodigoActionPerformed
       
    }//GEN-LAST:event_txtEmpresaCodigoActionPerformed

    private void txtEmpresaRazaoSocialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtEmpresaRazaoSocialActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtEmpresaRazaoSocialActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnNovo;
    private javax.swing.JButton btnPesquisar;
    private javax.swing.JButton btnRemover;
    private javax.swing.JButton btnSalvar;
    private javax.swing.JComboBox comboEmpresaCidade;
    private javax.swing.JComboBox comboEmpresaEstado;
    private javax.swing.JLabel labeEmpresaCNPJ;
    private javax.swing.JLabel labelEmpresaBairro;
    private javax.swing.JLabel labelEmpresaCidade;
    private javax.swing.JLabel labelEmpresaCodigo;
    private javax.swing.JLabel labelEmpresaEmail;
    private javax.swing.JLabel labelEmpresaEndereco;
    private javax.swing.JLabel labelEmpresaEstado;
    private javax.swing.JLabel labelEmpresaInscriacoEstadual;
    private javax.swing.JLabel labelEmpresaRazaoSocial;
    private javax.swing.JLabel labelEmpresaTelefone;
    private javax.swing.JPanel painelCentralEmpresa;
    private javax.swing.JTextField txtEmpresaBairro;
    private javax.swing.JTextField txtEmpresaCNPJ;
    private javax.swing.JTextField txtEmpresaCodigo;
    private javax.swing.JTextField txtEmpresaEmail;
    private javax.swing.JTextField txtEmpresaEndereco;
    private javax.swing.JTextField txtEmpresaInscricaoEstadual;
    private javax.swing.JTextField txtEmpresaRazaoSocial;
    private javax.swing.JTextField txtEmpresaTelefone;
    // End of variables declaration//GEN-END:variables

      
     @Override
    public void setCodigo(int codigo) {
        this.txtEmpresaCodigo.setText((Integer.toString(codigo)));
    }

    @Override
    public int getCodigo() {
        return Integer.parseInt(txtEmpresaCodigo.getText());
    }

    @Override
    public void setRazaoSocial(String razaoSocial) {
        this.txtEmpresaRazaoSocial.setText(razaoSocial);
    }

    @Override
    public String getRazaoSocial() {
        return txtEmpresaRazaoSocial.getText();
    }

    @Override
    public void setCnpj(String cnpj) {
        this.txtEmpresaCNPJ.setText(cnpj);
    }

    @Override
    public String getCnpj() {
        return txtEmpresaCNPJ.getText();
    }

    @Override
    public void setInscricaoEstadual(String inscricaoEstadual) {
        this.txtEmpresaInscricaoEstadual.setText(inscricaoEstadual);
    }

    @Override
    public String getInsciacaoEstadual() {
        return txtEmpresaInscricaoEstadual.getText();
    }

    @Override
    public void setEndereco(String endereco) {
        this.txtEmpresaEndereco.setText(endereco);
    }

    @Override
    public String getEndereco() {
        return txtEmpresaEndereco.getText();
    }

    @Override
    public void setBairro(String bairro) {
        this.txtEmpresaBairro.setText(bairro);
    }

    @Override
    public String getBairro() {
        return txtEmpresaBairro.getText();
    }

    @Override
    public void setCidade(List<CidadeModel> listaCidades) {
        
        for(int i = 0; i < listaCidades.size(); i++) // Percorro o Array List com o For aprimorado.  
        {  
            this.comboEmpresaCidade.addItem(listaCidades.get(i).getNomeCidade()); // Adiciono os dados.  
        } 
    }

    @Override
    public String getCidade() {
        return comboEmpresaCidade.getSelectedItem().toString();
    }

    @Override
    public void setEstado(List<EstadoModel> listaEstados) {
        
        for(int i = 0; i < listaEstados.size(); i++) // Percorro o Array List com o For aprimorado.  
        {  
            this.comboEmpresaEstado.addItem(listaEstados.get(i).getNomeEstado()); // Adiciono os dados.  
        }
    }

    @Override
    public String getEstado() {
        return comboEmpresaEstado.getSelectedItem().toString();
    }

    @Override
    public void setTelefone(String telefone) {
        this.txtEmpresaTelefone.setToolTipText(telefone);
    }

    @Override
    public String getTelefone() {
        return txtEmpresaTelefone.getText();
    }

    @Override
    public void setEmail(String email) {
        this.txtEmpresaEmail.setToolTipText(email);
    }

    @Override
    public String getEmail() {
        return txtEmpresaEmail.getText();
    }

    @Override
    public void packAndShow() {
        //this.pack();  
        ConfiguracaoInstancias.getDesktop().getDesktop().add(this);
        this.setVisible(true);
    }

    @Override
    public void clearFields() {
        Component[] componentesPainel;         
                componentesPainel = painelCentralEmpresa.getComponents();
                for (int j = 0; j < componentesPainel.length; j++) {
                    if(componentesPainel[j] instanceof JTextField){
                       JTextField field = (JTextField)componentesPainel[j];
                       field.setText(""); 
                    }
                }
    }
   
    @Override
    public void enableTxtEmpresaCodigo(boolean arg) {
        txtEmpresaCodigo.setEnabled(arg);
    }

    @Override
    public void enableTxtEmpresaRazaoSocial(boolean arg) {
        txtEmpresaRazaoSocial.setEnabled(arg);
    }

    @Override
    public void enableTxtEmpresaCnpj(boolean arg) {
        txtEmpresaCNPJ.setEnabled(arg);
    }

    @Override
    public void enableTxtEmpresaInscriacaoEstadual(boolean arg) {
        txtEmpresaInscricaoEstadual.setEnabled(arg);
    }

    @Override
    public void enableTxtEmpresaEndereco(boolean arg) {
        txtEmpresaEndereco.setEnabled(arg);
    }

    @Override
    public void enableTxtEmpresaBairro(boolean arg) {
        txtEmpresaBairro.setEnabled(arg);
    }

    @Override
    public void enableTxtEmpresaCidade(boolean arg) {
        comboEmpresaCidade.setEnabled(arg);
    }

    @Override
    public void enableTxtEmpresaEstado(boolean arg) {
        comboEmpresaEstado.setEnabled(arg);
    }

    @Override
    public void enableTxtEmpresaTelefone(boolean arg) {
        txtEmpresaTelefone.setEnabled(arg);
    }

    @Override
    public void enableTxtEmpresaEmail(boolean arg) {
        txtEmpresaEmail.setEnabled(arg);
    }

    @Override
    public void enableBtnAlterar(boolean arg) {
        this.btnPesquisar.setEnabled(arg);
    }

    @Override
    public void enableBtnRemover(boolean arg) {
        this.btnRemover.setEnabled(arg);
    }

    @Override
    public void enableBtnCancelar(boolean arg) {
        this.btnCancelar.setEnabled(arg);
    }

    @Override
    public void enableBtnSalvar(boolean arg) {
        this.btnSalvar.setEnabled(arg);
    }

    @Override
    public void enableBtnInserir(boolean arg) {
        this.btnNovo.setEnabled(arg);
    }

    @Override
    public void setInserirActionListener(ActionListener listener) {
        this.btnNovo.addActionListener(listener); 
    }

    @Override
    public void setRemoverActionListener(ActionListener listener) {
        this.btnRemover.addActionListener(listener); 
    }

    @Override
    public void setAlterarActionListener(ActionListener listener) {
        this.btnPesquisar.addActionListener(listener);
    }

    @Override
    public void setCancelarActionListener(ActionListener listener) {
        this.btnCancelar.addActionListener(listener); 
    }

    @Override
    public void setSalvarActionListener(ActionListener listener) {
        this.btnSalvar.addActionListener(listener); 
    }

    @Override
    public void setBtnSairActionListener(ActionListener listener) {
        //this.btnSair.addActionListener(listener); 
    }

    @Override
    public void removeAllitensComboCidade() {
        this.comboEmpresaCidade.removeAllItems();
    }

    @Override
    public void removeAllitensComboEstado() {
        this.comboEmpresaEstado.removeAllItems();
    }
        
}
